import { useModel } from "umi";
import { useReactive } from "ahooks";

const useDeleteGatewayInfo = (personUuid) => {
    const { remoteData } = useModel("global");
    const { baseInfo } = useModel("person.info");

    const state = useReactive({
        loading: false,
        gateways: [],
    });

    const deletePersonGateway = async (uuid, callback) => {
        if (!baseInfo?.uuid) return;
        state.loading = true;
        let res = await remoteData({
            object: "base-platform-management-service",
            serviceName: "/person/gateway/delete",
            params: {
                personUuid: baseInfo.uuid,
                uuid,
            },
        });
        callback && callback(res);
        state.loading = false;
        return res;
    };

    return { ...state, deletePersonGateway };
};

export default useDeleteGatewayInfo;
